#ifndef __DEF_SETTINGDIALOG_H__
#define __DEF_SETTINGDIALOG_H__

#include <wx/wx.h>
#include <wx/notebook.h>
#include <wx/datectrl.h>
#include <wx/listctrl.h>
#include <wx/spinctrl.h>
#include "appconstant.h"
#include "dbkakeibo.h"
#include "de_dialog.h"
#include <vector>

class SettingDialog: public wxDialog
{
public:
	SettingDialog(wxWindow *parent);
	~SettingDialog(void)
	{
		de_dialog->Close();
	}
	void BindData_Setting(DB_setting &db);
	DB_setting &GetData_Setting(void);
	void SetInitialMode(bool flag);
	void SetAccount(void);
protected:
	wxNotebook *st_mainPanel;
		wxPanel *st_generalPanel;
			wxTextCtrl *st_UserName;
			wxTextCtrl *st_BookName;
			wxDatePickerCtrl *st_StartDate;
			wxSpinCtrl *st_InitialRemainder;
			wxSpinCtrl *st_SettlingDay;
			wxSpinCtrl *st_SettlingMonth;
			wxCheckBox *st_SettlingLastDay;
			wxTextCtrl *st_CurrencyUnit;
			wxChoice *st_StartWeekDay;
			wxTextCtrl *st_IconPath;
			wxButton *st_IconRefBtn;
			wxTextCtrl *st_FontInfo;
			wxButton *st_FontRefBtn;
			wxCheckBox *st_EncryptFile;
		wxPanel *st_periodicPanel;
			wxListCtrl *st_PeriodicalList;
			wxButton *st_AddPeriodic;
			wxButton *st_ModPeriodic;
			wxButton *st_DelPeriodic;
			wxButton *st_InputBaseInfo;
			wxCheckBox *st_SetAfterInputValue;
			wxCheckBox *st_SetAfterInputMemo;
			wxChoice *st_PeriodicalTiming;
			wxSpinCtrl *st_TimingDay;
			wxRadioBox *st_CaseHolidayTiming;
		wxPanel *st_holidayPanel;
			wxListCtrl *st_HolidayList;
			wxButton *st_AddHoliday;
			wxButton *st_ModHoliday;
			wxButton *st_DelHoliday;
			wxDatePickerCtrl *st_HolidayDate;
			wxTextCtrl *st_HolidayName;
			wxButton *st_ImportHoliday;
		wxPanel *st_budgetPanel;
			wxListCtrl *st_BudgetList;
			wxButton *st_AddBudget;
			wxButton *st_ModBudget;
			wxButton *st_DelBudget;
			wxChoice *st_BudgetType;
			wxChoice *st_BudgetHandle;
			wxDatePickerCtrl *st_BudgetStart;
			wxDatePickerCtrl *st_BudgetEnd;
			wxSpinCtrl *st_BudgetValue;
	
	wxButton *st_OkBtn;
	wxButton *st_CanBtn;
	DetailEditor *de_dialog;
	void st_OkBtn_clicked(wxCommandEvent &event);
	void st_CanBtn_clicked(wxCommandEvent &event);
	void st_AddPeriodic_clicked(wxCommandEvent &event);
	void st_ModPeriodic_clicked(wxCommandEvent &event);
	void st_DelPeriodic_clicked(wxCommandEvent &event);
	void st_InputBaseInfo_clicked(wxCommandEvent &event);
	void st_PeriodicalTiming_selected(wxCommandEvent &event);
	void st_PeriodicalList_selected(wxListEvent &event);
	void st_AddHoliday_clicked(wxCommandEvent &event);
	void st_ModHoliday_clicked(wxCommandEvent &event);
	void st_DelHoliday_clicked(wxCommandEvent &event);
	void st_HolidayList_selected(wxListEvent &event);
	void st_ImportHoliday_clicked(wxCommandEvent &event);
	void st_BudgetList_selected(wxListEvent &event);
	void st_AddBudget_clicked(wxCommandEvent &event);
	void st_ModBudget_clicked(wxCommandEvent &event);
	void st_DelBudget_clicked(wxCommandEvent &event);
	void st_BudgetType_clicked(wxCommandEvent &event);
	void st_SettlingLastDay_changed(wxCommandEvent &event);
	void st_IconRefBtn_clicked(wxCommandEvent &event);
	void st_FontRefBtn_clicked(wxCommandEvent &event);

private:
	wxPanel *setup_generalpage(wxNotebook *book);
	wxPanel *setup_periodicpage(wxNotebook *book);
	wxPanel *setup_holidaypage(wxNotebook *book);
	wxPanel *setup_budgetpage(wxNotebook *book);
	void InsertRow(wxListCtrl *lstcrtl, wxString list[], size_t size);
	void ChangeRow(wxListCtrl *lstcrtl, int index, wxString list[], size_t size);
	void DeleteRow(wxListCtrl *lstcrtl, int index);
	void CalculateSettleDate(wxDateTime *stdate, wxDateTime *eddate);
	bool CheckBudget(DB_reserved &db);
private:
	DECLARE_EVENT_TABLE()
	DBL_periodical dbperiod;
	DBL_holiday dbholiday;
	DBL_reserved dbreserved;
	int listselect;
	int listselect_holiday;
	int listselect_budget;
	bool isinputbase;
	bool isinitial;
	DB_setting setdb;
	std::vector<int> dbaccountId;
	wxFont deffont;
};

enum {
	setting_ok = 50,
	setting_can,
	setting_add,
	setting_mod,
	setting_del,
	setting_periolist,
	setting_baseinfo,
	setting_periotiming,
	setting_holidaylist,
	setting_addholiday,
	setting_modholiday,
	setting_delholiday,
	setting_importholiday,
	setting_budgetlist,
	setting_addbudget,
	setting_modbudget,
	setting_delbudget,
	setting_budgettype,
	setting_settlelastday,
	setting_iconrefbtn,
	setting_fontrefbtn
};
#endif